package com.tedu.ds.consumables.controller;

import com.tedu.ds.base.response.JsonResult;
import com.tedu.ds.consumables.pojo.dto.ConsumablesParam;
import com.tedu.ds.consumables.pojo.dto.ConsumablesQuery;
import com.tedu.ds.consumables.pojo.vo.ConsumablesPage;
import com.tedu.ds.consumables.pojo.vo.ConsumablesVO;
import com.tedu.ds.consumables.service.ConsumablesService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/v1/consumables")
@Api(tags = "耗材模块")
public class ConsumablesController {
    @Autowired
    private ConsumablesService consumablesService;
    @PostMapping("/save")
    @ApiOperation(value = "新增、修改耗材信息")
    public JsonResult save(@RequestBody ConsumablesParam param){
        consumablesService.save(param);
        return JsonResult.ok();
    }
    @DeleteMapping("/delete/{id}")
    public JsonResult deleteById(@PathVariable Long id){
        consumablesService.deleteById(id);
        return JsonResult.ok();
    }
    @PostMapping("/select")
    @ApiOperation(value = "查询耗材信息")
    public JsonResult select(@RequestBody ConsumablesQuery query){
        ConsumablesPage list = consumablesService.select(query);
        return JsonResult.ok(list);
    }

}
